const fnDebugLog = require('debug')('decorator')

export const Controller = (root: string) => (target:any) => {
  fnDebugLog('!!!!! decorator', target)
  target.prototype.root = root;
}

export const Get = (route?:string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
  if (!target.handlersOfGet) target.handlersOfGet = []
  target.handlersOfGet.push({
    route: route ?? '',
    method: propertyKey
  })
  const method = descriptor.value;
  descriptor.value = function (...args:any[]) {
    console.log('++++++', args, method);
    let result = method.apply(this, args);
    console.log('------');
    return result
  }
}
